# coding: utf-8
from sqlalchemy import BigInteger, Column, DateTime, Float, String
from sqlalchemy.schema import FetchedValue
from flask_sqlalchemy import SQLAlchemy

db = SQLAlchemy()


class FilesUpload(db.Model):
    __tablename__ = 'files_upload'

    id = db.Column(db.BigInteger, primary_key=True)
    user_id = db.Column(db.BigInteger)
    file_name = db.Column(db.String(255), info='file name')
    target_path = db.Column(db.String(255))
    insert_time = db.Column(db.DateTime, server_default=db.FetchedValue())


class Record(db.Model):
    __tablename__ = 'record'

    id = db.Column(db.BigInteger, primary_key=True)
    line = db.Column(db.BigInteger)
    ctime = db.Column(db.DateTime)
    note_line = db.Column(db.BigInteger)
    blank_line = db.Column(db.BigInteger)
    actual_line = db.Column(db.BigInteger)
    actual_line_rate = db.Column(db.Float)
    note_line_rate = db.Column(db.Float)
    blank_line_rate = db.Column(db.Float)
    user_id = db.Column(db.BigInteger)
    file_id = db.Column(db.BigInteger)
    file_name = db.Column(db.String(255))


class UserInfo(db.Model):
    __tablename__ = 'user_info'

    id = db.Column(db.BigInteger, primary_key=True)
    nickname = db.Column(db.String(255))
    user = db.Column(db.String(255))
    pwd = db.Column(db.String(255))
    insert_time = db.Column(db.DateTime, server_default=db.FetchedValue())
